package com.toubutu.audio.admin.dto;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.toubutu.audio.admin.entity.User;
import com.toubutu.audio.common.QueryBaseDto;
import com.toubutu.constants.BaseConstants;

import lombok.Data;
import org.apache.commons.lang3.StringUtils;

/**
 * @author 戒躁
 * @version 1.0
 * @date 2023年10月30日 19:44
 */
@Data
public class AdminUserQueryDto extends QueryBaseDto<User> {

    private Long userId;
    private String email;
    private String nickName;
    @Override
    public LambdaQueryWrapper<User> getWrapper() {
        LambdaQueryWrapper<User> wrapper = new LambdaQueryWrapper<>();
        wrapper.eq(User::getIsDelete, BaseConstants.UN_DELETED);
        if (userId!=null){
            wrapper.eq(User::getUserId,userId);
        }
        if (StringUtils.isNotBlank(email)){
            wrapper.eq(User::getEmail,email);
        }
        if (StringUtils.isNotBlank(nickName)){
            wrapper.like(User::getNickName,getNickName());
        }
        return wrapper;
    }
}
